package JUnit4;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

public class LiczbaTest {
	
	Liczba testedObject = null;

	@Before
	public void setUp() throws Exception {
		this.testedObject = new Liczba(0);
	}

	@After
	public void tearDown() throws Exception {
		this.testedObject = null;
	}
	
	@Test
	public void checkNULLReference() {
		assertNotNull(this.testedObject);
	}
	
	@Test(expected = NumberOutOfBoundsException.class)
	public void checkSetter1() throws NumberOutOfBoundsException {
		this.testedObject.setLiczba(-1);
	}
	
	@Test
	public void checkSetter2() throws NumberOutOfBoundsException {
		this.testedObject.setLiczba(0);
		this.testedObject.setLiczba(1);

	}
	
	@Test(expected = WrongBaseException.class)
	public void checkBase117() throws NumberOutOfBoundsException, WrongBaseException {
		this.testedObject.setLiczba(10);
		this.testedObject.getNumberInBase(1);
		this.testedObject.getNumberInBase(17);
	}
	
	@Test
	public void checkBase216() throws NumberOutOfBoundsException, WrongBaseException {
		this.testedObject.setLiczba(10);
		assertEquals(this.testedObject.getNumberInBase(2), "1010");
		assertEquals(this.testedObject.getNumberInBase(16), "A");
	}
	
	@Test
	public void checkZero() throws NumberOutOfBoundsException, WrongBaseException {
		this.testedObject.setLiczba(0);
		
		assertEquals("0", this.testedObject.getNumberInBase(2));
		assertEquals("0", this.testedObject.getNumberInBase(3));
		assertEquals("0", this.testedObject.getNumberInBase(4));
		assertEquals("0", this.testedObject.getNumberInBase(5));
		assertEquals("0", this.testedObject.getNumberInBase(6));
		assertEquals("0", this.testedObject.getNumberInBase(7));
		assertEquals("0", this.testedObject.getNumberInBase(8));
		assertEquals("0", this.testedObject.getNumberInBase(9));
		assertEquals("0", this.testedObject.getNumberInBase(10));
		assertEquals("0", this.testedObject.getNumberInBase(11));
		assertEquals("0", this.testedObject.getNumberInBase(12));
		assertEquals("0", this.testedObject.getNumberInBase(13));
		assertEquals("0", this.testedObject.getNumberInBase(14));
		assertEquals("0", this.testedObject.getNumberInBase(15));
		assertEquals("0", this.testedObject.getNumberInBase(16));
	}
	
	@Test(timeout = (long) 0.0000000000001)
	public void checkOne() throws NumberOutOfBoundsException, WrongBaseException {
		this.testedObject.setLiczba(1);
		
		assertEquals("1", this.testedObject.getNumberInBase(2));
		assertEquals("1", this.testedObject.getNumberInBase(3));
		assertEquals("1", this.testedObject.getNumberInBase(4));
		assertEquals("1", this.testedObject.getNumberInBase(5));
		assertEquals("1", this.testedObject.getNumberInBase(6));
		assertEquals("1", this.testedObject.getNumberInBase(7));
		assertEquals("1", this.testedObject.getNumberInBase(8));
		assertEquals("1", this.testedObject.getNumberInBase(9));
		assertEquals("1", this.testedObject.getNumberInBase(10));
		assertEquals("1", this.testedObject.getNumberInBase(11));
		assertEquals("1", this.testedObject.getNumberInBase(12));
		assertEquals("1", this.testedObject.getNumberInBase(13));
		assertEquals("1", this.testedObject.getNumberInBase(14));
		assertEquals("1", this.testedObject.getNumberInBase(15));
		assertEquals("testCheck1 failed on base 16","1", this.testedObject.getNumberInBase(16));
	}
	
	@Ignore
	public void ignoredCase() throws NumberOutOfBoundsException {
		this.testedObject.setLiczba(-10);
	}
	
	
}
